﻿OB.Emes_ActionButton = OB.Emes_ActionButton || {};
	//工序绑定工艺标准上传
OB.Emes_ActionButton.uploadorderimport  = function(d,b) {
		var e = b.activeView.viewGrid;
		var a = e.getSelectedRecord();
		if(a == null || a._entityName != 'Emes_Process'){
			top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
			return false;
		}
			// 选择纪录行
		OB.Layout.ClassicOBCompatibility.Popup.open('uploadorder', 500, 100,OB.Application.contextUrl + 'web/com.mes/html/uploadorder.html?wmlm_id='+a.id,    
					'工序工艺标准上传', window, false, false, null, true, true);
			OB.Emes_ActionButton.MyRefresh=function(){
				b.view.viewGrid.refreshGrid();
			}
}

//工序绑定作业指导书
OB.Emes_ActionButton.Insertsorderimport  = function(d,b) {
		var e = b.activeView.viewGrid;
		var a = e.getSelectedRecord();
		if(a == null || a._entityName != 'Emes_Process'){
			top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
			return false;
		}
			// 选择纪录行
		OB.Layout.ClassicOBCompatibility.Popup.open('Insertsorder', 500, 100,OB.Application.contextUrl + 'web/com.mes/html/Insertsorder.html?wmlm_id='+a.id,  
					'工序作业指导书上传', window, false, false, null, true, true);
			OB.Emes_ActionButton.MyRefresh=function(){
				b.view.viewGrid.refreshGrid();
			}
}

//形体部位查看图片
OB.Emes_ActionButton.CheckPBomItem  = function(d,b) {
    var e = b.activeView.viewGrid;
    var a = e.getSelectedRecord();
    if(a == null || a._entityName != 'Emes_PBom_Item'){
        top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
        return false;
    }
    if(a.filePath == null){
        top.isc.showMessage("该型体部位未上传图片。",top.isc.OBMessageBar.TYPE_SUCCESS);
    	return;
	}

    isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(a.filePath) + "&online=true&fileName=" + encodeURIComponent(a.fileName)}).show();

}

//物料绑定产品图纸
OB.Emes_ActionButton.Productdrawingimport  = function(d,b) {
		var e = b.activeView.viewGrid;
		var a = e.getSelectedRecord();
		if(a == null || a._entityName != 'Product'){
			top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
			return false;
		}
			// 选择纪录行
		OB.Layout.ClassicOBCompatibility.Popup.open('Productdrawing', 500, 100,OB.Application.contextUrl + 'web/com.mes/html/Productdrawing.html?wmlm_id='+a.id,  
					'产品图纸上传', window, false, false, null, true, true);
			OB.Emes_ActionButton.MyRefresh=function(){
				b.view.viewGrid.refreshGrid();
			}
}

//物料查看产品图纸
OB.Emes_ActionButton.CheckProductdrawing  = function(d,b) {
    var e = b.activeView.viewGrid;
    var a = e.getSelectedRecord();
    OB.RemoteCallManager.call("com.mes.handler.CheckProductHandler",
        {productId: a.id},
        {},
        function(response, data, request) {
            if(data.flag){
                isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(data.meg) + "&online=true&fileName=" + data.names}).show();
            }else{
                top.isc.showMessage("该物料未上传图片。",top.isc.OBMessageBar.TYPE_SUCCESS);
            }
        }
    );
}
//形状管理查看上传图片
OB.Emes_ActionButton.CheckShapePhoto  = function(d,b) {
    var e = b.activeView.viewGrid;
    var a = e.getSelectedRecord();
    if(a == null || a._entityName != 'Emes_Shape'){
        top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
        return false;
    }
    if(a.filePath == null){
        top.isc.showMessage("该图案/形状未上传图片。",top.isc.OBMessageBar.TYPE_SUCCESS);
        return;
    }

    isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(a.filePath) + "&online=true&fileName=" + encodeURIComponent(a.fileName)}).show();
}
//BOM查看文件
OB.Emes_ActionButton.CheckBomFile  = function(d,b) {
    var e = b.activeView.viewGrid;
    var a = e.getSelectedRecord();
    if(a == null || a._entityName != 'Emes_PBom_Item_Shape'){
        top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
        return false;
    }
    if(a.dataFilePath == null){
        top.isc.showMessage("未上传文件。",top.isc.OBMessageBar.TYPE_SUCCESS);
        return;
    }

    isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(a.dataFilePath) + "&online=true&fileName=" + encodeURIComponent(a.fileName)}).show();
}
//员工基础信息身份证正反面上传
OB.Emes_ActionButton.employeeimport  = function(d,b) {
		var e = b.activeView.viewGrid;
		var a = e.getSelectedRecord();
		if(a == null || a._entityName != 'Emes_Employee'){
			top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
			return false;
		}
			// 选择纪录行
		OB.Layout.ClassicOBCompatibility.Popup.open('EMPLOYEE', 500, 420,OB.Application.contextUrl + 'web/com.mes/html/employee.html?wmlm_id='+a.id,
					'身份证正反面上传', window, false, false, null, true, true);
			OB.Emes_ActionButton.MyRefresh=function(){
				b.view.viewGrid.refreshGrid();
			}
}